<template>
  <div>
      <div class="title">
         <span @click="$router.push('/')" class="index">首页</span>/<span>发布文章</span>
      </div>
      <el-form ref="form" :model="form" label-width="80px">
       <el-form-item label="标题">
            <el-input v-model="form.name"></el-input>
       </el-form-item>
       <el-form-item label="内容">
            <VueEditor></VueEditor>
       </el-form-item>
  <el-form-item label="栏目" >
    <el-checkbox-group v-model="form.type">
      <el-checkbox label="美食/餐厅线上活动" name="type"></el-checkbox>
      <el-checkbox label="地推活动" name="type"></el-checkbox>
      <el-checkbox label="线下主题活动" name="type"></el-checkbox>
      <el-checkbox label="单纯品牌曝光" name="type"></el-checkbox>
    </el-checkbox-group>
  </el-form-item>
  <el-form-item label="封面">
    <el-upload
  action="#"
  list-type="picture-card"
  :auto-upload="false">
    <i slot="default" class="el-icon-plus"></i>
    <div slot="file" slot-scope="{file}">
      <img
        class="el-upload-list__item-thumbnail"
        :src="file.url" alt=""
      >
      <span class="el-upload-list__item-actions">
        <span
          class="el-upload-list__item-preview"
          @click="handlePictureCardPreview(file)"
        >
          <i class="el-icon-zoom-in"></i>
        </span>
        <span
          v-if="!disabled"
          class="el-upload-list__item-delete"
          @click="handleDownload(file)"
        >
          <i class="el-icon-download"></i>
        </span>
        <span
          v-if="!disabled"
          class="el-upload-list__item-delete"
          @click="handleRemove(file)"
        >
          <i class="el-icon-delete"></i>
        </span>
      </span>
    </div>
</el-upload>
<el-dialog :visible.sync="dialogVisible">
  <img width="100%" :src="dialogImageUrl" alt="">
</el-dialog>
       </el-form-item>
  <el-form-item label="类型">
    <el-radio-group v-model="form.resource">
      <el-radio label="文章"></el-radio>
      <el-radio label="视频"></el-radio>
    </el-radio-group>
  </el-form-item>
  <el-form-item>
    <el-button type="primary" @click="onSubmit">提交</el-button>
  </el-form-item>
</el-form>    
  </div>
</template>

<script>
import { VueEditor } from "vue2-editor";
export default {
  components:{
      VueEditor
  },
  data() {
      return {
        form: {
          name: '',
          region: '',
          date1: '',
          date2: '',
          delivery: false,
          type: [],
          resource: '',
          desc: '',
        },
         dialogImageUrl: '',
        dialogVisible: false,
        disabled: false
      }
    },
    methods: {
      onSubmit() {
        console.log('submit!');
      },
       handleRemove(file) {
        console.log(file);
      },
      handlePictureCardPreview(file) {
        this.dialogImageUrl = file.url;
        this.dialogVisible = true;
      },
      handleDownload(file) {
        console.log(file);
      }
    }
}
</script>

<style lang="less" scoped>
.title{
    padding-left:45px;
    margin-bottom: 10px;
    .index{
        :hover{color: red};
        
    }
}
</style>